/*
 * Created on 2006-2-10
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.hitrust.gs.action;

import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.date.DateUtil;
import com.hitrust.gs.util.exception.GSException;
import com.hitrust.gs.bean.GSBalanceParamBean;
import com.hitrust.gs.bean.GSOperatorBean;

import com.hitrust.gs.dao.GSBalanceParamDAO;
/**
 * @author simonyi
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class GSSystemParamSaveAction extends GSBaseAction {

    public String execute(GSBaseForm aForm) throws Exception {
        
        GSOperatorBean operatorBean = (GSOperatorBean)aForm.getSession().getAttribute(GSBaseConstants.LOGIN);

        String period = aForm.getRequest().getParameter("period");
        String datetype = aForm.getRequest().getParameter("datetype");
        String startdate = aForm.getRequest().getParameter("startdate");
        String enddate = aForm.getRequest().getParameter("enddate");
        

        GSBalanceParamDAO dao = new GSBalanceParamDAO();
        GSBalanceParamBean tBean = new GSBalanceParamBean();
        tBean.setGs_balance_date_type(datetype);
        tBean.setGs_balance_period(period);
        tBean.setGs_balance_start_date(startdate);
        tBean.setGs_balance_end_date(enddate);
        tBean.setGs_operator_id(operatorBean.getGs_oper_id());
        tBean.setGs_operate_date(DateUtil.getCurrentDate("yyyyMMDD"));
        
        try{
            dao.saveBalanceParam(tBean);
            tBean = null;
            tBean = dao.queryBalanceDate();
            aForm.getRequest().setAttribute("MSG","系统参数设置成功");
            aForm.getRequest().setAttribute("bean",tBean);
        }catch(GSException gse){
            aForm.getRequest().setAttribute("action","A400701");
            throw gse;
        }
        
        
        return GSBaseConstants.FORWARD_SUCCESS;
    }
}